package com.ityedao.IO缓冲流.IO字节缓冲流;

import java.io.*;

public class Test {
    public static void main(String[] args) {
        try (
                InputStream is = new FileInputStream("src\\ityedao.txt");
                // 1、定义一个字节缓冲输入流包装原始的字节输入流
                InputStream bis = new BufferedInputStream(is, 8192 * 2); // 底层的缓冲池可以扩大

                OutputStream os = new FileOutputStream("src\\ityedao-copy001.txt");
                // 2、定义一个字节缓冲输出流包装原始的字节输出流
                OutputStream bos = new BufferedOutputStream(os, 8192 * 2);
        ) {
            byte[] buffer = new byte[1024];
            int len;
            while((len = bis.read(buffer)) != -1){
                bos.write(buffer, 0, len);
            }
            System.out.println("复制完成！");
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
